The present invention relates to computer systems. More specifically, the invention relates to providing a time-to-live timeout on a connection that is borrowed from a connection cache.
In computer systems, it is common for an application to obtain a connection to a desired resource. An application programming interface (API) can define the calls that obtain a connection, access the resource, close a connection, and the like. For example, the Java database connectivity (JDBC) is an API that allows Java applications to connect and access databases.
Establishing a connection and closing a connection can take unwanted time and processing capability. Accordingly, it is known to pool connections in a connection cache. When an application wants a connection from the cache, a request for a connection from the cache is sent and fulfilled with a connection from the cache (or a new connection). When that application is finished with the connection, the application closes the connection and the connection is returned to the cache. Thus, if another application (or the same one at a later point in time) requests a connection from the cache, the connection can be readily been given from the cache, if available.
Applications, however, do not always utilize connections in an ideal manner. Sometimes, an application will not return a connection when it is finished. For example, an application that dies due to an exception may not inform the cache manager that it is done with the connection. Accordingly, some connection cache implementations utilize an abandoned timeout that will return a connection to the cache if the connection has not been active for a specified amount of time.
Just as it may be undesirable to have an application not use a connection for a relatively long period of time, it may also be undesirable to have a connection in the cache that has not been utilized for a specified amount of time. Accordingly, an inactivity timeout can be utilized to close connections that have been in the cache unused for a period of time longer than the timeout.
Although these mechanisms have improved the efficiency of connection cache systems, it would be desirable to have innovative techniques of improving the efficiency of connection caches. Additionally, it would be beneficial if this functionality could be achieved without requiring unnecessary changes to applications requesting and using the connections.